/* 
 *  Incub - incubate your baby robot
 *  Copyright (C) 2008 Stanislaw Szymczyk
 *  e-mail: sszymczy@gmail.com   www: http://cogville.cog-lab.com
 *
 *  This file is part of Incub.
 *
 *  Incub is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  Incub is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Incub.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */
 
#include "Material.h"

using std::string;

Material::Material() {
	name = default_name;
	ambient.r = 0.2;
	ambient.g = 0.2;
	ambient.b = 0.2;
	diffuse.r = 0.8;
	diffuse.g = 0.8;
	diffuse.b = 0.8;
	specular.r = 0.5;
	specular.g = 0.5;
	specular.b = 0.5;
	emission.r = 0;
	emission.g = 0;
	emission.b = 0;
	shininess = 100.0;
	density = 1;
	
	friction = 0.6;
	resilience = 10000;
	damping = 10;
}

string Material::default_name = "default";

void Material::setName(string& name) {
	this->name = name;
}

string& Material::getName() {
	return name;
}

string& Material::getDefaultName() {
	return default_name;
}

void Material::setAmbient(string amb) {
	sscanf(amb.c_str(), "%f %f %f", &ambient.r, &ambient.g, &ambient.b);
}

void Material::setDiffuse(string diff) {
	sscanf(diff.c_str(), "%f %f %f", &diffuse.r, &diffuse.g, &diffuse.b);
}

void Material::setSpecular(string spec) {
	sscanf(spec.c_str(), "%f %f %f", &specular.r, &specular.g, &specular.b);
}

void Material::setEmission(string spec) {
	sscanf(spec.c_str(), "%f %f %f", &emission.r, &emission.g, &emission.b);
}

void Material::setShininess(string shin) {
	shininess = atof(shin.c_str());
}

Color& Material::getAmbient() {
	return ambient;;
}

Color& Material::getDiffuse() {
	return diffuse;;
}

Color& Material::getSpecular() {
	return specular;;
}

Color& Material::getEmission() {
	return emission;
}

float Material::getShininess() {
	return shininess;
}

void Material::setDensity(string density) {
	this->density = atof(density.c_str());
}

float Material::getDensity() {
	return density;
}

void Material::setFriction(string friction) {
	this->friction = atof(friction.c_str());
}

float Material::getFriction() {
	return friction;
}

void Material::setResilience(string resilience) {
	this->resilience = atof(resilience.c_str());
}

float Material::getResilience() {
	return resilience;
}

void Material::setDamping(string damping) {
	this->damping = atof(damping.c_str());
}

float Material::getDamping() {
	return damping;
}
